package leetcode.editor.week.week305;

import java.util.HashSet;
import java.util.Set;

public class Solution6136 {
    public int arithmeticTriplets(int[] nums, int diff) {
        Set<Integer> set = new HashSet<>();
        for(int num : nums) {
            set.add(num);
        }

        int count = 0, res = 0;
        for(int num : nums) {
            count = 1;
            int one = num;
            int two = num + diff;
            int three = two + diff;
            if(set.contains(two) && set.contains(three)) {
                res++;
            }
        }

        return res;
    }
}
